package com.blithe.wgt.httpService;


import com.blithe.wgt.entity.Path;
import com.blithe.wgt.entity.Task;
import com.blithe.wgt.http.ObjectLoader;
import com.blithe.wgt.http.RetrofitServiceManager;
import com.blithe.wgt.http.response.BaseResponse;

import java.util.List;

import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.POST;
import rx.Observable;

public class TaskLoader extends ObjectLoader {
    private TaskService taskService;

    public TaskLoader() {
        taskService = RetrofitServiceManager.getInstance().createJsonService(TaskService.class);
    }

    public Observable<BaseResponse<List<Path>>> getPathList() {
        return observe(taskService.getPathList());

    }

    public Observable<BaseResponse<String>> postTask(Task task) {
        return observe(taskService.postTask(task));

    }

    interface TaskService {

        @GET("getPath")
        Observable<BaseResponse<List<Path>>> getPathList();

        @POST("start")
        Observable<BaseResponse<String>> postTask(@Body Task task);

    }
}
